﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BaseSet.Data;
using BaseSet.Logic;
using BaseSet.Entity;
using BaseSet.Framework;
using BaseSet.Entity.Common;
using BaseSet.Entity.Common.Text;
using BaseSet;
using System.Data;


namespace WebSite.Help
{
    public partial class HelpContent : PreBasePage
    {
        private string newtypeid = "";
        public string strseo = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            newtypeid = Request.QueryString["id"] + "";
            if (newtypeid == "")
            {
                Response.Redirect("../Index.aspx");
                return;
            }
            //newtypeid = newtypeid.Substring(0, newtypeid.Length - 1);
            if (!Page.IsPostBack)
            {
                LoadContent();
                BindSeo();
            }
        }

        #region 加载内容
        private void LoadContent()
        {
            News ninfo = new News();
            NewsHelper nhelper = new NewsHelper();
            Criteria c = new Criteria();
            c.Add(CriteriaType.Equals, "NewsTypeID", newtypeid);
            c.Add(CriteriaType.Equals, "Flag", 0);
            List<News> nlist = nhelper.QueryNewsBySearch(c, null);
            if (nlist != null && nlist.Count > 0)
            {
                ninfo = nlist[0];
                lblContent.Text = ninfo.NewsContent;

                //加载类别名称
                NewsType ntypeinfo = new NewsType();
                NewsTypeHelper ntypehelper = new NewsTypeHelper();
                ntypeinfo = ntypehelper.GetNewsType(newtypeid);
                litTypeName.Text = ntypeinfo.NewsTypeName;
            }
        }
        #endregion

        #region 加载SEO信息
        private void BindSeo()
        {
            string typename = litTypeName.Text.Trim();

            string systemkeyword = System.Configuration.ConfigurationManager.AppSettings["keyword"] + "";
            string systemdescription = System.Configuration.ConfigurationManager.AppSettings["description"] + "";

            string author = System.Configuration.ConfigurationManager.AppSettings["author"] + "";
            string copyright = System.Configuration.ConfigurationManager.AppSettings["copyright"] + "";

            string keyword = typename+ " " + systemkeyword + " " + author;
            string title = author + "-" + typename;

            strseo += "<title>" + title + "</title>\r\n";
            strseo += "<meta name=\"keywords\" content=\"" + keyword + "\" />\r\n";
            strseo += "<meta name=\"description\" content=\"" + systemdescription + "\" />\r\n";
            strseo += "<meta name=\"author\" content=\"" + author + "\" />\r\n";
            strseo += "<meta name=\"Copyright\" content=\"" + copyright + "\" />\r\n";
        }
        #endregion
    }
}